package cn.edu.lingnan.association.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.association.dao.UserDAO;
import cn.edu.lingnan.association.dto.User;


public class SignupServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException {
		
	 String mid = req.getParameter("mid");
	 String username1 = req.getParameter("username");
	 System.out.println(username1);
	 String password = req.getParameter("password1");
	 int ssuper = Integer.parseInt(req.getParameter("ssuper"));
	 
	 User u = new User();
	 UserDAO ud = new UserDAO();	 
	 u.setmId(mid);
	 u.setusername(username1);
	 u.setpassword(password);
	 u.setssuper(ssuper);
	 int flag = ud.insertInfoToUser(u);	
	 if(flag == 1)
		 resp.sendRedirect(req.getContextPath()+"/index.html");
	 else
		 resp.sendRedirect(req.getContextPath()+"/signup.html");
	}

}
